package com.asianrapid.controller.sys;


import com.asianrapid.model.sys.LqraEntity;
import com.asianrapid.model.sys.LqrjEntity;
import com.asianrapid.model.sys.PageResult;
import com.asianrapid.service.sys.LqraService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class LqraController {

    private Logger log = LoggerFactory.getLogger(LqraController.class);

    @Autowired
    private LqraService lqraService;
    /*查出所有信息*/
   @GetMapping("/lqras")
    public PageResult getalllqra(int pageSize, int page){

        PageResult pageResult = new PageResult();
        List<LqraEntity> alllqra = lqraService.getalllqra(pageSize,page * pageSize);
        int total= lqraService.getCount();
        pageResult.setData(alllqra);
        pageResult.setTotalCount(total);
        return pageResult;
    }
    /*新增信息*/
    @PostMapping("/insertlqra")
    public void insert (@RequestBody LqraEntity lqraEntity){
        System.out.println(lqraEntity);
        lqraService.insertlqra(lqraEntity);
    }
    /*修改信息*/
    @PutMapping("/updatelqra")
    public LqraEntity update(@RequestBody LqraEntity lqraEntity){

        lqraService.updatelqra(lqraEntity);


        return lqraEntity;
    }

    @PostMapping("/getByIda")
    public LqraEntity getByIda(@RequestBody List<Integer> groupId){


        return  lqraService.getById(groupId.get(0));
    }


    /*删除信息*/
    @DeleteMapping("/deletelqra")
    public List<String> delete(@RequestBody List<String> groupId){
        lqraService.deletelqra(groupId);
        return groupId;
    }
}
